#include <iostream>
#include <string>

using namespace std;
class Personlist{
public:
    Personlist(){};
    Personlist(const string new_name[],int new_size);
    void set_name(const string&new_name,int i);
    void disp();

private:
    string* nameist;
    int size;
};
void Personlist::set_name(const string &new_name, int i) {
    nameist[i] = new_name;
}
Personlist::Personlist(const string *new_name, int new_size) {
    nameist = new string [size = new_size];
    for (int i = 0; i < new_size; i++) {
        nameist[i]= new_name[i];
    }
}
void Personlist::disp() {
    cout<<"The names are";
    for(int i = 0;i<size;i++){
        cout<<nameist[i]<<"\t";

    }
            cout<<endl;
}
int main(){
    string namelist[3]={"Tom","Jack","Allen"};
    Personlist p1(namelist,3);
    Personlist p2(p1);
    cout<<"改变之前"<<endl;
    p1.disp();
    p2.disp();
    p2.set_name("Peter",1);
    cout<<"改变之后"<<endl;
    p1.disp();
    p2.disp();
    cout<<endl;
    return 0;
}